package com.yu.dv.entity.res;

import lombok.Data;

import java.util.Map;

@Data
public class ExecutionResult {
    private final boolean success;
    private Map<String, Object> data;
    private final String message;

    private ExecutionResult(boolean success, String message, Map<String, Object> data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    private ExecutionResult(boolean success, String message) {
        this.success = success;
        this.message = message;
    }

    public static ExecutionResult success(String message, Map<String, Object> data) {
        return new ExecutionResult(true, message, data);
    }

    public static ExecutionResult success(String message) {
        return new ExecutionResult(true, message, null);
    }

    public static ExecutionResult error(String message) {
        return new ExecutionResult(false, message);
    }

    public static ExecutionResult error(String message, Map<String, Object> errorData) {
        return new ExecutionResult(false, message, errorData);
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }
}